﻿
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>daojishi</title>

</head>
<body>
    <div id="djs">


    </div>
    <script>
    function formatDate(data){

     	return  Math.floor(data/3600)+"小时"+Math.floor(data%3600/60) +"分"+Math.floor(data%3600%60)+"秒" ;
		}
        function daojishi() {
            this.startNumber =2*3600+ 1*60+10;
            this.endNumber = 0;
            this.indexNumber = 10;
            this.nodeId = "djs";
            this.timer = null;


            if (typeof (daojishi.initailed) == "undefined") {
                daojishi.prototype.draw = function () {
                    var obj = document.getElementById(this.nodeId);
                    this.indexNumber--;
                    obj.innerHTML = "<b style='font-size: -webkit-xxx-large;'>" + formatDate(this.indexNumber) + "</b>";
                    if (this.indexNumber == 0) {
                        window.clearInterval(this.timer);
                    }
                }
                daojishi.prototype.start = function () {
                    this.indexNumber = this.startNumber;
                    var self = this;
                    this.timer = window.setInterval(function () { self.draw() }, 1000, this);
                }
            }
        }
    new daojishi().start();
    </script>
</body>
</html>
